package com.lin.controller;

import com.lin.entity.User;
import com.lin.service.UserService;
import io.swagger.annotations.ApiOperation;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName UserController
 * @Description TODO
 * @Author Li
 * @Date 2022/1/24 22:11
 * @Version 1.0
 **/
@RestController
@CrossOrigin
public class UserController {
    @Resource
    private UserService userService;

    @ApiOperation(value = "查询所有",notes = "查询所有用户信息")
    @GetMapping("/users")
    public List<User> users(){
        List<User> users = userService.list();
        return users;
    }

    @GetMapping("/delete")
    public String delete(Integer id){
        boolean remove = users().remove(id);
        return "redirect:/users";
    }



}
